package com.liuyjy.encryptDecrypt;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;

import java.io.IOException;

public class CryptoScalarDeserializer extends JsonDeserializer<Object> {
    @Override
    public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        JsonNode node = p.getCodec().readTree(p);
        String value = node.asText();
        // 假设 decrypt 是一个解密方法
        return decrypt(value);
    }

    private String decrypt(String encryptedValue) {
        // 实现解密逻辑
        return "decrypted_" + encryptedValue;
    }
}